const http = require('http');

http.createServer((request, response) => {
    let body = [];
    request.on('error', (error) => {
        console.log(error);
    })
    .on('data', (chunk) => {
        // console.log(chunk);
        body.push(chunk.toString());
    })
    .on('end', () => {
        // 下面这一行一值报错, 无法理解啊
        // body = Buffer.concat(body).toString();
        console.log(body.toString());
        response.writeHead(200, {'Content-Type': 'text/html'});
        response.end(`<html>
            <head>
                <title>测试parser dom</title>
            </head>
            <body>
                <h1>你好的解析器</h1>
            </body>
        </html>
        `);
    });
}).listen(8099);

console.log("server started");